<cfcomponent output="false">
	
	<!--- --->
	
	<cffunction name="date" access="public" output="true" returntype="string">
		<cfargument name="date" required="true" />
		<cfargument name="mask" required="false" default="yyyy-mm-dd" />
		<cfargument name="time" required="false" default="true" />
		
		<cfset var local = {} />
		
		<cfset local.date = dateFormat(arguments.date,arguments.mask) />
		<cfif arguments.time>
			<cfset local.date = local.date & " 00:00:00" />
		</cfif>
		
		<cfreturn local.date />

	</cffunction>
	
	<!--- --->
	
	<cffunction name="encrypt" access="public" output="false" returntype="string">
		<cfargument name="string" required="true" />
		<cfargument name="key" required="false" default="##" />
		
		<cfreturn encrypt(arguments.string,application.helpers.site.getVar("encryptKey"),'desede','base64') />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="decrypt" access="public" output="false" returntype="string">
		<cfargument name="string" required="true" />
		<cfif len(arguments.string) gt 3>
			<cftry>
				<cfreturn decrypt(arguments.string,application.helpers.site.getVar("encryptKey"),'desede','base64') />
				<cfcatch>
					<cfreturn "" />
				</cfcatch>
			</cftry>
		<cfelse>
			<cfreturn arguments.string />
		</cfif>
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="money" access="public" output="false" returntype="string">
		<cfargument name="amount" required="true" />
		<cfargument name="isDecimal" required="false" default="true" />
		<cfargument name="dollarSign" required="false" default="true" />
		
		<cfset var local = {} />

		<cfif arguments.isDecimal>
			<cfset local.mask = "9,999.99" />
		<cfelse>
			<cfset local.mask = "," />
		</cfif>
		
		<cfif arguments.dollarSign>
			<cfset local.pre = "$" />
		<cfelse>
			<cfset local.pre = "" />
		</cfif>
		
		<cfset local.money = trim(numberFormat(arguments.amount,local.mask)) />
		
		<cfreturn local.pre & local.money />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="encode" access="public" output="false" returntype="string">
		<cfargument name="string" required="true" />
		
		<cfset var local = {} />
		
		<cfset local.encoded = CharsetDecode(arguments.string,'utf-8') />
		<cfset local.encoded = binaryEncode(local.encoded,"Base64") />
		
		<cfreturn local.encoded />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="decode" access="public" output="false" returntype="string">
		<cfargument name="string" required="true" />
		
		<cfset var local = {} />
		
		<cfset local.decoded = binaryDecode(arguments.string,'Base64') />
		<cfset local.decoded = CharsetEncode(local.decoded,"utf-8") />
				
		<cfreturn local.decoded />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="sha1" access="public" output="false" returntype="string">
		<cfargument name="key" required="true" />
		<cfargument name="message" required="true" />
		
		<cfset var local = {} />

		<cfset local.signingKey = createObject('java','javax.crypto.spec.SecretKeySpec').init(arguments.key.getBytes(),'HmacSHA1') />
		<cfset local.mac = createObject('java','javax.crypto.Mac').getInstance('HmacSHA1') />
		<cfset local.mac.init(local.signingKey) />

		<cfreturn toBase64(local.mac.doFinal(arguments.message.getBytes())) />
		
<!--- 		<cfset local.jMessage = javaCast("string",arguments.message).getBytes('UTF-8') />
		<cfset local.jKey = javaCast("string",arguments.key).getBytes("UTF-8") />
		
		<Cfset local.key = createObject('java','javax.crypto.spec.SecretKeySpec') />
		<cfset local.mac = createObject('java','javax.crypto.Mac') />
		
		<cfset local.thisKey = local.key.init(local.jKey,'HmacSHA1') />
		<cfset local.thisMac = local.mac.getInstance(local.thisKey.getAlgorithm()) />
		
		<cfset local.thisMac.init(local.thisKey) />
		<cfset local.thisMac.update(local.jMessage) />
		
		<cfreturn URLEncodedFormat(toBase64(local.thisMac.doFinal())) /> --->
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="s3signature" access="public" output="false" returntype="struct">
		
		<cfset var local = {} />
		
		<cfset local.BASE64Encoder = createObject('java','sun.misc.BASE64Encoder').init() />
		<cfset local.BASE64Encoder2 = createObject('java','sun.misc.BASE64Encoder').init() />
		
		<cfset local.policy = encode(application.helpers.site.getVar('AWSpolicy')) />
		<cfset local.secret = javaCast("string",application.helpers.site.getVar('AWSaccessKeySecret')).getBytes("UTF-8") />
		
		<cfset local.result = {} />
		<cfset local.result.policy = "" />
		<cfset local.result.signature = "" />

		<cfset local.Mac = createObject('java','javax.crypto.Mac').getInstance("HmacSHA1") />
		
		<cfset local.SecretKeySpec = createObject('java','javax.crypto.spec.SecretKeySpec').init(local.secret,"HmacSHA1") />
		<cfset local.Mac.init(local.SecretKeySpec) />

		<cfset local.result.policy = local.policy />
		
		<cfset local.result.signature = local.base64encoder.encode(local.Mac.doFinal(local.policy.getBytes("UTF-8"))).replaceAll("\n","") />

		<cfreturn local.result />

	</cffunction>
	
	<!--- --->
	
	<cffunction name="humanize" access="public" output="false" returntype="string">
		<cfargument name="string" required="true" />
		
		<cfset var local = {} />

		<cfset local.array = listToArray(arguments.string,'_') />
		<cfset local.result = "" />
		
		<cfloop array="#local.array#" index="local.i" item="local.item">
			<cfif local.i gt 1>
				<cfset local.result = local.result & ' ' />
			</cfif>
			<cfset local.result = local.result & ucase(left(local.item,1)) />
			<cfif len(local.item) gt 1>
				<cfset local.result = local.result & right(local.item,len(local.item)-1) />
			</cfif>
		</cfloop>
		
		<cfreturn local.result />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="full_name" access="public" output="false" returntype="string">
		<cfargument name="first_name" required="false" default="" />
		<cfargument name="middle_name" required="false" default="" />
		<cfargument name="last_name" required="false" default="" />
		
		<cfset var local = {} />

		<cfset local.name = "" />

		<cfif arguments.first_name neq ''>
			<cfset local.name = arguments.first_name />
			<cfif arguments.last_name neq ''>
				<cfif arguments.middle_name neq ''>
					<cfset local.name = local.name & ' ' & left(arguments.middle_name,1) & '.' />
				</cfif>
				<cfset local.name = local.name & ' ' & arguments.last_name />
			</cfif>
		<cfelse>
			<cfif arguments.last_name neq ''>
				<cfset local.name = arguments.last_name />
			</cfif>
		</cfif>
		
		<cfreturn local.name />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="paragraph" access="public" output="false" returntype="string">
		<cfargument name="string" required="false" default="" />
		<cfargument name="input" required="false" default="false" />
		<cfargument name="javascript" required="false" default="false" />
		
		<cfset var local = {} />
		
		<cfset local.replacement = '</br>'>
		<cfif arguments.input>
			<cfset local.replacement = '&##10;' />
		</cfif>
		
		<cfif arguments.javascript>
			<cfset local.replacement = '\n' />
		</cfif>
		
		<cfset local.result = rereplace(arguments.string, '\n',local.replacement, 'ALL') />
		
		<cfreturn local.result />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="humanizeTime" access="public" output="false" returntype="string">
		<cfargument name="string" required="true" hint="HH:mm:ss" />
		<cfargument name="short" required="false" default="false" />
		
		<cfif arguments.short>
			<cfif minute(arguments.string) eq 0>
				<cfreturn lcase(timeFormat(arguments.string,"htt")) />
			<cfelse>
				<cfreturn lcase(timeFormat(arguments.string,"h:mmtt")) />
			</cfif>
		<cfelse>
			<cfreturn timeFormat(arguments.string,"h:mm tt") />
		</cfif>
		
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="humanizeDate" access="public" output="false" returntype="string">
		<cfargument name="string" required="true" hint="MM/DD/YYYY" />
		<cfargument name="format" required="false" default="m/d/yy" />

		<cfreturn dateFormat(arguments.string,arguments.format) />
		
	</cffunction>
	
	<!--- --->


</cfcomponent>